<template>
	<view class="content">
		<view class="example">
			<view>
				<uni-grid :column="4" :highlight="true" @change="change">
					<uni-grid-item v-for="(item, index) in studentList" :index="index" :key="index">
						<view class="grid-item-box" style="background-color: #fff;">
							<image :src="item.photograph" style="width: 100px; height: 70px"></image>
							<text class="text">{{ item.name }}</text>
						</view>
					</uni-grid-item>
				</uni-grid>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getStudentInfoListBySchoolId
	} from "@/api/jz/school/info"
	import {
		getInfoId
	} from '@/utils/auth';

	export default {
		data() {
			return {
				studentList: []
			}
		},
		methods: {
			getStudentInfoListBySchoolIdFun(schoolId) {
				getStudentInfoListBySchoolId(schoolId).then((res) => {
					if (res.code == 200) {
						this.studentList = res.data
					}
				})
			},
			change(e) {
				let index = e.detail.index
				let student = this.studentList[index]
                

				uni.navigateTo({
					url: '/pages/school/list?data=' + encodeURIComponent(JSON.stringify(student))
				})
			}
		},
		onLoad: function() {
			this.getStudentInfoListBySchoolIdFun(getInfoId())
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.example {
		padding: 15px;
		background-color: #fff;
	}

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
		flex: 1;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		line-height: 35px;
		margin-left: 10px;
	}

	.image {
		width: 25px;
		height: 25px;
	}

	.text {
		font-size: 14px;
		margin-top: 5px;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		// display: block;
		/* #endif */
	}

	.grid-dynamic-box {
		margin-bottom: 15px;
	}

	.grid-item-box {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		text-align: center;
		margin-top: 20px;
		margin-bottom: 10px;
		// padding: 15px 0;
	}

	.grid-item-box-row {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.grid-dot {
		position: absolute;
		top: 5px;
		right: 15px;
	}

	.swiper {
		height: 420px;
	}

	/* #ifdef H5 */
	@media screen and (min-width: 768px) and (max-width: 1425px) {
		.swiper {
			height: 630px;
		}
	}

	@media screen and (min-width: 1425px) {
		.swiper {
			height: 830px;
		}
	}

	/* #endif */
</style>